package com.longtop.framework.sys.login.web;

import java.util.HashMap;
import java.util.List;

import com.longtop.framework.base.BaseAction;
import com.longtop.framework.base.BaseService;
import com.longtop.framework.security.SessionObject;
import com.longtop.framework.util.BeanUtil;
import com.longtop.framework.util.SpringBeanFactory;
import com.longtop.framework.util.StringUtil;
import com.longtop.intelliweb.action.IInitContext;
import com.longtop.intelliweb.view.Dataset;
import com.longtop.intelliweb.view.Text;

/**
 * 首页选择--对公贷款趋势图
 * 
 * @author 胡砥峰
 * @version 1.0
 */
public class Home3Action extends BaseAction {

	/**
	 * 系统共用：初始化调用
	 */
	public void init(IInitContext context) {
		super.init(context);
	}

	/**
	 * 本页jsp：初始化业务数据(覆写父类方法)
	 */
	public void thisPageInit(IInitContext context) {

		BaseService baseService = SpringBeanFactory.getBean(BaseService.BEAN_ID); // 调用spring的业务逻辑
		SessionObject sessionObject = this.getSessionObject(context);

		String chartType = StringUtil.getString(context.getRequest().getParameter("chartType")); // 图形类型
		Text text = (Text) context.getControl("chartType");
		text.setValue(chartType);

		try {
			Dataset dataset = context.getDataset("Dataset_Home");
			HashMap hashMap = new HashMap();
			String filterSql = "and A.VALUE_TYPE =3";
			hashMap.put("filterSql", filterSql);// 金额类型3 对公贷款
			String filter = "";
			filter = sessionObject.getGrantFilterSql("T_SYS_ORG", "O", "ORG_ID", null);
			hashMap.put("grantFilterSql", filter);
			List list = baseService.queryForListByIbatis("homeChartSql.searchHomeChart", hashMap);

			BeanUtil.listToDataset(list, dataset);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
